part of IFinal;

//==================================== Config Server ====================================
class _IFinal_ConfigModel_Server {
  String notice = "";
  List<String> lines = [];
  late _LoginModel login;
  int historyMaxCount = 0; //搜索历史最大记录数量

  _IFinal_ConfigModel_Server.fromJson(Map<String, dynamic> map) {
    notice = map["notice"]?.toString() ?? "";
    lines = ((map["lines"] ?? []) as List).map((e) => e.toString()).toList();
    login = _LoginModel.fromJson(map["login"] as Map<String, dynamic>);
    historyMaxCount = double.parse(map["historyMaxCount"]?.toString() ?? "0").toInt();
  }
}

class _LoginModel {
  _LoginModel();

  bool account = false; //账号登录
  bool third = false; //三方登录
  bool verify = false; //免验证码登录
  bool code_server = false; //短信验证码_Server
  bool code_sdk = false; //短信验证码_SDK

  _LoginModel.fromJson(Map<String, dynamic>? map) {
    if (map == null) return;
    account = map["account"] ?? false;
    third = map["third"] ?? false;
    verify = map["verify"] ?? false;
    code_server = map["code_server"] ?? false;
    code_sdk = map["code_sdk"] ?? false;
  }
}

//==================================== Config Local ====================================
class _IFinal_ConfigModel_Local {
  bool debug_onLine = false;
  String scheme = "";
  String md5Key = "";
  List<String> config_lines = [];
  late _ThirdSDKModel third_sdk;

  _IFinal_ConfigModel_Local.fromJson(Map<String, dynamic> map) {
    debug_onLine = map["debug_onLine"] ?? false;
    scheme = map["scheme"]?.toString() ?? "";
    md5Key = map["md5Key"]?.toString() ?? "";
    config_lines = ((map["config_lines"][(!YConfig.DEBUG || debug_onLine) ? "release" : "debug"] ?? []) as List).map((e) => e.toString()).toList();
    third_sdk = _ThirdSDKModel.fromJson(map["third_sdk"] as Map<String, dynamic>);
  }
}

class _ThirdSDKModel {
  _ThirdSDKModel();

  late _ShareSDKModel shareSDK;
  late _YIM yim;
  late _OSS oss;

  _ThirdSDKModel.fromJson(Map<String, dynamic>? map) {
    if (map == null) return;
    shareSDK = _ShareSDKModel.fromJson(map["shareSDK"] as Map<String, dynamic>);
    yim = _YIM.fromJson(map["yim"] as Map<String, dynamic>);
    oss = _OSS.fromJson(map["oss"] as Map<String, dynamic>);
  }
}

class _ShareSDKModel {
  _ShareSDKModel();

  String QQ_Key = "";
  String QQ_Secret = "";
  String WeChat_Key = "";
  String WeChat_Secret = "";

  _ShareSDKModel.fromJson(Map<String, dynamic>? map) {
    if (map == null) return;
    QQ_Key = map["QQ_Key"]?.toString() ?? "";
    QQ_Secret = map["QQ_Secret"]?.toString() ?? "";
    WeChat_Key = map["WeChat_Key"]?.toString() ?? "";
    WeChat_Secret = map["WeChat_Secret"]?.toString() ?? "";
  }
}

class _YIM {
  _YIM();

  String appKey = "";

  _YIM.fromJson(Map<String, dynamic>? map) {
    if (map == null) return;
    appKey = map["appKey"]?.toString() ?? "";
  }
}

class _OSS {
  _OSS();

  String ossEndpoint = "";
  String bucketName = "";
  String accessKey = "";
  String accessSecret = "";
  String expire = "";

  _OSS.fromJson(Map<String, dynamic>? map) {
    if (map == null) return;
    ossEndpoint = map["ossEndpoint"]?.toString() ?? "";
    bucketName = map["bucketName"]?.toString() ?? "";
    accessKey = map["accessKey"]?.toString() ?? "";
    accessSecret = map["accessSecret"]?.toString() ?? "";
    expire = map["expire"]?.toString() ?? "";
  }
}
